package com.hongyuan.coach.ui.person.view_mode;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.coach.base.CustomViewModel;
import com.hongyuan.coach.data.Constants;
import com.hongyuan.coach.data.MyRepository;
import com.hongyuan.coach.ui.person.activity.CoachDetailsActivity;
import com.hongyuan.coach.ui.person.activity.SettingActivity;
import com.hongyuan.coach.ui.person.activity.VersionInforActivity;
import com.hongyuan.coach.ui.person.beans.CoachDeatilsBean;

public class PersonViewModel extends CustomViewModel<MyRepository> {

    public ObservableField<CoachDeatilsBean.InfoBean> entity = new ObservableField<>();

    public PersonViewModel(@NonNull Application application, MyRepository model) {
        super(application, model);
    }

    //教练主页
    public BindingCommand goDetails = new BindingCommand(() -> {
        startActivity(CoachDetailsActivity.class);
    });
    //设置
    public BindingCommand goSetting = new BindingCommand(() -> {
        startActivity(SettingActivity.class);
    });
    //关于我们
    public BindingCommand goAboutUs = new BindingCommand(() -> {
        startActivity(VersionInforActivity.class);
    });

    @Override
    public void onResume() {
        super.onResume();

        requestData(Constants.GET_COACH_INDEX_INFO);
    }


    @Override
    protected void returnData(int code, Object dataBean) {
        super.returnData(code, dataBean);

        if(code == Constants.GET_COACH_INDEX_INFO){
            CoachDeatilsBean.InfoBean infoBean = ((CoachDeatilsBean)dataBean).getInfo();
            userToken.setOs_id(String.valueOf(infoBean.getCoach_os_id()));
            entity.set(infoBean);
        }

    }
}
